<template>
  <!-- 添加或修改付款申请单对话框 -->
  <el-dialog :title="title" :visible.sync="open" width="80%" append-to-body :close-on-click-modal="false" v-dialogDrag>

    <el-form ref="form" :model="form" :rules="rules" label-width="120px">
      <el-tabs v-model="activeName" class="detail-tab" type="card">
        <el-row :gutter="20">
          <el-col :span="24">
            <el-form-item label="审核意见" prop="assessOpinion">
              <el-input type="textarea" v-model="form.assessOpinion" placeholder="请输入审核意见"/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-tabs>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="danger" @click="submitForm('3')">退 回</el-button>
      <el-button type="primary" @click="submitForm('4')">通 过</el-button>
      <el-button @click="cancel">取 消</el-button>
    </div>
  </el-dialog>
</template>

<script>
import {accAdd, addAction, getAction, getById, postAction, updateAction} from '@/api/manage';
import moment from 'moment';
import {parseTime} from "@/utils/common";
import BuyGoodsList from "@/views/develop/payApply/module/BuyGoodsList.vue";
import FileUploadShow from "@/components/FileUpload/FileUploadShow.vue";

export default {
  name: "PayApplyAssessFormBatch",
  components: {FileUploadShow, BuyGoodsList},
  dicts: ["apply_pay_status", "apply_assess_status"],
  data() {
    return {
      // 遮罩层
      loading: true,
      activeName: "first",
      // 弹出层标题
      title: "",
      // 是否显示弹出层
      open: false,
      queryParams: {
        pageNum: 1,
        pageSize: 20,
        mainId: null,
      },
      // 总条数
      total: 0,
      // 表单参数
      form: {},
      buyDetailList:[],
      payApplyBuyList:[],
      CS: {
        'text-align': 'center',  //文本居中
        'min-width': '250px',   //最小宽度
        'word-break': 'break-all'  //过长时自动换行
      },
      LS: {
        'color': '#000',
        'text-align': 'center',
        'font-weight': '600',
        'height': '40px',
        'min-width': '110px',
        'word-break': 'keep-all'
      },
      // 表单校验
      rules: {
        assessOpinion:[
          {required: true, message: '请输入审核意见', trigger: 'blur'}
        ]
      },
      url: {
        assessBatch: '/payApply/payApply/assessBatch',
      },
      buyId:null,
      payApplyBuyDetailList:[],
    };
  },
  created() {

  },
  methods: {
    // 取消按钮
    cancel() {
      this.open = false;
      this.reset();
    },
    // 表单重置
    reset() {
      this.form = {
        id: null,
        type: null,
        buyId: null,
        invoiceCode: null,
        invoicePhoto: null,
        totalMoney: null,
        paidMoney: null,
        remainMoney: null,
        assessOpinion: null,
        remark: null,
      };
      this.resetForm("form");
    },
    /** 新增按钮操作 */
    handleAdd() {
      this.reset();
      this.open = true;
      this.title = "添加付款申请单";
    },
    /** 修改按钮操作 */
    handleBatchAssess(ids) {
      this.reset();
      this.ids = ids;
      this.title = "批量审核付款申请单";
      this.open = true;
    },

    /** 提交按钮 */
    submitForm(assessStatus) {
      this.form.assessStatus = assessStatus;
      this.$refs["form"].validate(valid => {
        if (valid) {
          let params = {"ids": this.ids.join(","), "assessOpinion": this.form.assessOpinion, "assessStatus": assessStatus};
            postAction(this.url.assessBatch, params).then(response => {
              this.$modal.msgSuccess("审核成功");
              this.open = false;
              this.$emit('ok');
            });
        }
      });
    },

  }
};
</script>
